package com.yqg.protection.listenern;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.yqg.protection.controller.dto.ImportEquipmentInputStoreDto;
import com.yqg.protection.entity.EquipmentInputStore;
import com.yqg.protection.mapper.EquipmentInputStoreMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * projectName:xf-service1
 * author:zxf
 * time:2024/10/17 16:32
 * description:
 */
@Component
public class EquipmentInputStoreListener extends AnalysisEventListener<ImportEquipmentInputStoreDto> {

    @Autowired
    private EquipmentInputStoreMapper equipmentInputStoreMapper;

    @Override
    public void invoke(ImportEquipmentInputStoreDto importEquipmentInputStoreDto, AnalysisContext analysisContext) {
        EquipmentInputStore equipmentInputStore = new EquipmentInputStore();
        BeanUtil.copyProperties(importEquipmentInputStoreDto, equipmentInputStore, true);
        equipmentInputStore.setIsDelete(0);
        equipmentInputStoreMapper.insert(equipmentInputStore);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
